package com.lc202309;

import java.util.*;

/**
 * Description:
 *
 * @Create 2023/9/20 23:35
 * @Version 1.0
 */
public class Solution136 {
    public int singleNumber(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        Set<Integer> set = new HashSet<>();
        int res = 0;
        for (int num : nums) {
            Integer tmp = map.getOrDefault(num, 0) + 1;
            map.put(num, tmp);
            if (tmp == 1) {
                set.add(num);
                continue;
            }
            set.remove(num);
        }
        return set.iterator().next();
    }
}
